/*
 * Copyright 2016-2019 yoara
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package yhao.infra.feature.dubbo;

import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.ServiceBean;

public class ConfigFactory {
    public static final String DUBBO_APPLICATION_ORG = "dubbo.application.org";         //dubbo应用所在组织名
    public static final String DUBBO_APPLICATION_OWNER = "dubbo.application.owner";     //dubbo应用从属人
    public static final String DUBBO_APPLICATION_NAME = "dubbo.application.name";       //dubbo应用名
    public static final String DUBBO_REGISTRY_ADDRESS = "dubbo.registry.address";       //dubbo注册中心地址，使用zookeeper协议
    public static final String DUBBO_PROTOCOL_PORT = "dubbo.protocol.port";             //dubbo应用端口
    public static final String LOGGER_APP = "logger.app";                               //dubbo注册应用文件锁地址，与日志记录通用

    public static ReferenceBean makeQuickReferenceBean(String id, Class<?> interfaceClass){
        ReferenceBean bean =  new ReferenceBean();
        bean.setLazy(true);
        bean.setId(id);
        bean.setInterface(interfaceClass);
        bean.setProtocol("dubbo");
        return bean;
    }

    public static ServiceBean makeQuickServiceBean(Class<?> interfaceClass, Object ref){
        ServiceBean bean =  new ServiceBean();
        bean.setInterface(interfaceClass);
        bean.setRef(ref);
        bean.setRetries(0);
        return bean;
    }
}
